Minor C API tweaks.

This commit is contained in:
casey langen 2023-04-17 21:22:03 -07:00
parent 37c0479e4c
commit 510dd2e30c
2 changed files with 12 additions and 7 deletions

View File

@ -1035,11 +1035,11 @@ class mcsdk_audio_player_callback_proxy: public Player::EventListener {
}
}
}
virtual void OnPlayerAlmostEnded(Player *player) {
virtual void OnPlayerStreamEof(Player *player) {
std::unique_lock<std::mutex> lock(this->context->event_mutex);
for (auto c : callbacks) {
if (c->on_almost_ended) {
c->on_almost_ended(mcsdk_audio_player { context });
if (c->on_stream_eof) {
c->on_stream_eof(mcsdk_audio_player { context });
}
}
}
@ -1055,18 +1055,18 @@ class mcsdk_audio_player_callback_proxy: public Player::EventListener {
std::unique_lock<std::mutex> lock(this->context->event_mutex);
for (auto c : callbacks) {
if (c->on_error) {
c->on_error(mcsdk_audio_player { context });
c->on_error(mcsdk_audio_player { context }, mcsdk_playback_error_open_failed);
}
}
}
virtual void OnPlayerDestroying(Player *player) {
std::unique_lock<std::mutex> lock(this->context->event_mutex);
this->context->player_finished = true;
for (auto c : callbacks) {
if (c->on_destroying) {
c->on_destroying(mcsdk_audio_player { context });
}
}
this->context->player_finished = true;
this->context->finished_condition.notify_all();
}
virtual void OnPlayerMixPoint(Player *player, int id, double time) {

View File

@ -90,6 +90,11 @@ typedef enum mcsdk_audio_output_code {
mcsdk_audio_output_error_buffer_written = -1
} mcsdk_audio_output_code;
typedef enum mcsdk_playback_error_code {
mcsdk_playback_error_unknown = -1,
mcsdk_playback_error_open_failed = 0,
} mcsdk_playback_error_code;
typedef enum mcsdk_time_change_mode {
mcsdk_time_change_mode_seek = 0,
mcsdk_time_change_mode_scrub = 1
@ -261,9 +266,9 @@ mcsdk_define_handle(mcsdk_db_transaction);
typedef struct mcsdk_audio_player_callbacks {
void (*on_prepared)(mcsdk_audio_player p);
void (*on_started)(mcsdk_audio_player p);
void (*on_almost_ended)(mcsdk_audio_player p);
void (*on_stream_eof)(mcsdk_audio_player p);
void (*on_finished)(mcsdk_audio_player p);
void (*on_error)(mcsdk_audio_player p);
void (*on_error)(mcsdk_audio_player p, mcsdk_playback_error_code ec);
void (*on_destroying)(mcsdk_audio_player p);
void (*on_mixpoint)(mcsdk_audio_player p, int id, double time);
} mcsdk_audio_player_callbacks;