Skip to content

Commit

Permalink
linux sync with win32 fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
microcai committed Mar 10, 2013
1 parent 30d91ac commit d344a4e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set(Boost_USE_STATIC_RUNTIME ON)

find_package( Boost 1.50 REQUIRED COMPONENTS thread filesystem)

add_definitions(-D__STDC_CONSTANT_MACROS)

#dont't define this, libbt need depreated api
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR})
Expand Down
16 changes: 8 additions & 8 deletions audio/sdl_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define __STDC_CONSTANT_MACROS

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -39,29 +39,29 @@ EXPORT_API int sdl_init_audio(void* ctx, uint32_t channels,
{
ao_context *ao = (ao_context*)ctx;
sdl_audio_render* sdl = NULL;
ao->audio_dev = (void*)(sdl = new sdl_audio_render);
return sdl->init_audio((void*)ao->audio_dev, channels, bits_per_sample, sample_rate, format) ? 0 : -1;
ao->priv = (void*)(sdl = new sdl_audio_render);
return sdl->init_audio((void*)ao->priv, channels, bits_per_sample, sample_rate, format) ? 0 : -1;
}

EXPORT_API int sdl_play_audio(void* ctx, uint8_t* data, uint32_t size)
{
ao_context *ao = (ao_context*)ctx;
sdl_audio_render* sdl = (sdl_audio_render*)ao->audio_dev;
sdl_audio_render* sdl = (sdl_audio_render*)ao->priv;
return sdl->play_audio(data, size);
}

EXPORT_API void sdl_audio_control(void* ctx, double l, double r)
{
ao_context *ao = (ao_context*)ctx;
sdl_audio_render* sdl = (sdl_audio_render*)ao->audio_dev;
sdl_audio_render* sdl = (sdl_audio_render*)ao->priv;
control_vol_t ctrl_vol = { l, r };
sdl->audio_control(CONTROL_SET_VOLUME, &ctrl_vol);
}

EXPORT_API void sdl_mute_set(void* ctx, int s)
{
ao_context *ao = (ao_context*)ctx;
sdl_audio_render* sdl = (sdl_audio_render*)ao->audio_dev;
sdl_audio_render* sdl = (sdl_audio_render*)ao->priv;
control_vol_t ctrl_vol;
ctrl_vol.mute = s;
sdl->audio_control(CONTROL_MUTE_SET, &ctrl_vol);
Expand All @@ -70,12 +70,12 @@ EXPORT_API void sdl_mute_set(void* ctx, int s)
EXPORT_API void sdl_destory_audio(void* ctx)
{
ao_context *ao = (ao_context*)ctx;
sdl_audio_render* sdl = (sdl_audio_render*)ao->audio_dev;
sdl_audio_render* sdl = (sdl_audio_render*)ao->priv;
if (sdl)
{
sdl->destory_audio();
delete sdl;
ao->audio_dev = NULL;
ao->priv = NULL;
}
}

Expand Down
7 changes: 7 additions & 0 deletions libav/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
#define __AVPLAYER_GLOBALS_H__

#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <libavcodec/avcodec.h>
#ifdef __cplusplus
}
#endif

struct AVFrame;
struct AVPacket;
Expand Down
17 changes: 7 additions & 10 deletions linux/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define __STDC_CONSTANT_MACROS

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
Expand All @@ -38,20 +38,19 @@ void player::init_file_source(source_context* sc)
{
sc->init_source = file_init_source;
sc->read_data = file_read_data;
sc->read_seek = file_read_seek;
sc->close = file_close;
sc->destory = file_destory;
sc->offset = 0;
}

void player::init_torrent_source(source_context* sc)
{
sc->init_source = bt_init_source;
sc->read_data = bt_read_data;
sc->video_media_info = bt_media_info;
sc->read_seek = bt_read_seek;
sc->read_seek = bt_read_seek;
sc->close = bt_close;
sc->destory = bt_destory;
sc->offset = 0;
sc->save_path = ".";
}

int player::open(const char* movie, int media_type)
Expand Down Expand Up @@ -183,12 +182,10 @@ int player::open(const char* movie, int media_type)
// 如果是bt类型, 则在此得到视频文件列表, 并添加到m_media_list.
if (media_type == MEDIA_TYPE_BT)
{
int i = 0;
media_info *media = m_avplay->m_source_ctx->media;
for (; i < m_avplay->m_source_ctx->media_size; i++)
bt_source_info *bt_info = &m_avplay->m_source_ctx->info.bt;
for (int i = 0; i < bt_info->info_size; i++)
{
std::string name;
name = media->name;
std::string name = std::string(bt_info->info[i].file_name);
m_media_list.insert(std::make_pair(filename, name));
}
}
Expand Down
14 changes: 7 additions & 7 deletions video/sdl_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,48 @@ EXPORT_API int sdl_init_video(void *ctx, int w, int h, int pix_fmt)
vo_context *vo = (vo_context *) ctx;
sdl_render *sdl = NULL;

vo->video_dev = (void *) (sdl = new sdl_render);
vo->priv = (void *) (sdl = new sdl_render);
return sdl->init_render(vo->user_data, w, h, pix_fmt) ? 0 : -1;
}

EXPORT_API int sdl_render_one_frame(void *ctx, AVFrame * data,
int pix_fmt, double pts)
{
vo_context *vo = (vo_context *) ctx;
sdl_render *sdl = (sdl_render *) vo->video_dev;
sdl_render *sdl = (sdl_render *) vo->priv;
return sdl->render_one_frame(data, pix_fmt) ? 0 : -1;
}

EXPORT_API void sdl_re_size(void *ctx, int width, int height)
{
vo_context *vo = (vo_context *) ctx;
sdl_render *sdl = (sdl_render *) vo->video_dev;
sdl_render *sdl = (sdl_render *) vo->priv;
sdl->re_size(width, height);
}

EXPORT_API void sdl_aspect_ratio(void *ctx, int srcw, int srch,
int enable_aspect)
{
vo_context *vo = (vo_context *) ctx;
sdl_render *sdl = (sdl_render *) vo->video_dev;
sdl_render *sdl = (sdl_render *) vo->priv;
sdl->aspect_ratio(srcw, srch, enable_aspect);
}

EXPORT_API int sdl_use_overlay(void *ctx)
{
vo_context *vo = (vo_context *) ctx;
sdl_render *sdl = (sdl_render *) vo->video_dev;
sdl_render *sdl = (sdl_render *) vo->priv;
return sdl->use_overlay()? 0 : -1;
}

EXPORT_API void sdl_destory_render(void *ctx)
{
vo_context *vo = (vo_context *) ctx;
sdl_render *sdl = (sdl_render *) vo->video_dev;
sdl_render *sdl = (sdl_render *) vo->priv;
if (sdl) {
sdl->destory_render();
delete sdl;
vo->video_dev = NULL;
vo->priv = NULL;
}
}

Expand Down

0 comments on commit d344a4e

Please sign in to comment.