Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/pbl/services/music.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void music_get_pos(uint32_t *track_pos_ms, uint32_t *track_length_ms);
int32_t music_get_playback_rate_percent(void);

//! @return The volume percentage.
uint8_t music_get_volume_percent(void);
uint8_t music_service_get_volume_percent(void);

//! Retrieve the current playback state.
MusicPlayState music_get_playback_state(void);
Expand All @@ -76,7 +76,7 @@ bool music_is_playback_state_reporting_supported(void);
bool music_is_progress_reporting_supported(void);

//! @return True if the service supports reporting of the current volume.
//! @see music_get_volume_percent
//! @see music_service_get_volume_percent
bool music_is_volume_reporting_supported(void);

//! Sends the command to the server. Commands are "unreliable", they are sent at "best effort".
Expand Down
3 changes: 2 additions & 1 deletion sdk/include/_pkjs_message_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
["addEventListener", "removeEventListener", "showSimpleNotificationOnPebble",
"sendAppMessage", "getTimelineToken", "timelineSubscribe",
"timelineUnsubscribe", "timelineSubscriptions", "getActiveWatchInfo",
"getAccountToken", "getWatchToken", "appGlanceReload"].forEach(
"getAccountToken", "getWatchToken", "appGlanceReload",
"playSound", "playSoundById", "playDefaultRingtone", "stopSound"].forEach(
function(elem, idx, arr) {
if ((elem in Pebble) || ((typeof __Pebble[elem]) !== 'function')) {
// This function has already been copied over or doesn't actually exist.
Expand Down
18 changes: 18 additions & 0 deletions src/fw/applib/music_service.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* SPDX-FileCopyrightText: 2024 Google LLC */
/* SPDX-License-Identifier: Apache-2.0 */

#include "music_service.h"
#include "syscall/syscall.h"
#include "pbl/services/music.h"

void music_volume_up(void) {
sys_music_command_send(MusicCommandVolumeUp);
}

void music_volume_down(void) {
sys_music_command_send(MusicCommandVolumeDown);
}

uint8_t music_get_volume_percent(void) {
return sys_music_get_volume_percent();
}
41 changes: 41 additions & 0 deletions src/fw/applib/music_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* SPDX-FileCopyrightText: 2024 Google LLC */
/* SPDX-License-Identifier: Apache-2.0 */

#pragma once

#include <stdint.h>

/**
* @file music_service.h
* @brief Music Service for controlling mobile device volume.
*/

/**
* @addtogroup Foundation
* @{
* @addtogroup MusicService
* @{
*/

/**
* Sends a "Volume Up" command to the mobile device.
* This command is sent to the currently active media player on the phone.
*/
void music_volume_up(void);

/**
* Sends a "Volume Down" command to the mobile device.
* This command is sent to the currently active media player on the phone.
*/
void music_volume_down(void);

/**
* Gets the current volume level of the mobile device's media player.
* @return Volume as a percentage from 0 to 100, or 255 if not available.
*/
uint8_t music_get_volume_percent(void);

/**
* @} // end addtogroup MusicService
* @} // end addtogroup Foundation
*/
5 changes: 2 additions & 3 deletions src/fw/process_management/pebble_process_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,9 @@ typedef enum {
// sdk.major:0x5 .minor:0x5f -- speaker_play_tone() now plays the exact frequency (rev 98)
// sdk.major:0x5 .minor:0x60 -- Add persist_get_max_size() for runtime persist storage capacity (rev 99)
// sdk.major:0x5 .minor:0x61 -- Add speaker_is_muted() for system-wide speaker mute query (rev 100)
// sdk.major:0x5 .minor:0x62 -- Add backlight_service_subscribe/unsubscribe for backlight on/off events (rev 101)

// sdk.major:0x5 .minor:0x63 -- Music Service volume control (rev 102)
#define PROCESS_INFO_CURRENT_SDK_VERSION_MAJOR 0x5
#define PROCESS_INFO_CURRENT_SDK_VERSION_MINOR 0x62
#define PROCESS_INFO_CURRENT_SDK_VERSION_MINOR 0x63

// The first SDK to ship with 2.x APIs
#define PROCESS_INFO_FIRST_2X_SDK_VERSION_MAJOR 0x4
Expand Down
2 changes: 1 addition & 1 deletion src/fw/services/music/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int32_t music_get_playback_rate_percent(void) {
return playback_rate_percent;
}

uint8_t music_get_volume_percent(void) {
uint8_t music_service_get_volume_percent(void) {
mutex_lock_recursive(s_music_ctx.mutex);
int32_t player_volume_percent = s_music_ctx.player_volume_percent;
mutex_unlock_recursive(s_music_ctx.mutex);
Expand Down
4 changes: 4 additions & 0 deletions src/fw/syscall/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,8 @@ WatchInfoColor sys_watch_info_get_color(void);
//! choice and avoid disturbing actions such as vibration if quiet time is active.
//! @return True, if Quiet Time is currently active.
bool sys_do_not_disturb_is_active(void);
// Music control syscalls
void sys_music_command_send(MusicCommand command);
uint8_t sys_music_get_volume_percent(void);

//! @} // end addtogroup Preferences
13 changes: 13 additions & 0 deletions src/fw/syscall/syscall_music.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* SPDX-FileCopyrightText: 2024 Google LLC */
/* SPDX-License-Identifier: Apache-2.0 */

#include "pbl/services/music.h"
#include "syscall/syscall_internal.h"

DEFINE_SYSCALL(void, sys_music_command_send, MusicCommand command) {
music_command_send(command);
}

DEFINE_SYSCALL(uint8_t, sys_music_get_volume_percent, void) {
return music_service_get_volume_percent();
}
2 changes: 1 addition & 1 deletion tests/fw/services/test_music_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void prv_receive_and_assert_volume_info(bool expect_is_handled) {
cl_assert_equal_i(e.type, PEBBLE_MEDIA_EVENT);
cl_assert_equal_i(e.media.type, PebbleMediaEventTypeVolumeChanged);

cl_assert_equal_i(music_get_volume_percent(), 0x33);
cl_assert_equal_i(music_service_get_volume_percent(), 0x33);

} else {
cl_assert_equal_i(e.type, PEBBLE_NULL_EVENT);
Expand Down
25 changes: 23 additions & 2 deletions tools/generate_native_sdk/exported_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You should also make sure you are obeying our API design guidelines:",
"https://pebbletechnology.atlassian.net/wiki/display/DEV/SDK+API+Design+Guidelines"
],
"revision" : "101",
"revision" : "102",
"version" : "2.0",
"files": [
"fw/drivers/ambient_light.h",
Expand Down Expand Up @@ -128,7 +128,8 @@
"fw/applib/voice/dictation_session.h",
"fw/applib/ui/content_indicator.h",
"fw/applib/rockyjs/rocky.h",
"fw/applib/unobstructed_area_service.h"
"fw/applib/unobstructed_area_service.h",
"fw/applib/music_service.h"
],
"exports": [
{
Expand Down Expand Up @@ -851,6 +852,26 @@
"name": "AppLogLevel"
}
]
}, {
"type": "group",
"name": "MusicService",
"exports": [
{
"type": "function",
"name": "music_volume_up",
"addedRevision": "102"
},
{
"type": "function",
"name": "music_volume_down",
"addedRevision": "102"
},
{
"type": "function",
"name": "music_get_volume_percent",
"addedRevision": "102"
}
]
}, {
"type": "group",
"name": "Dictionary",
Expand Down
Loading